# coding=utf-8


class Task(object):
    def __init__(self, task_id, node_id_list):
        self.task_id = task_id
        self.spider_no = 0
        self.status = '0' # 0=not_start, 10=starting, 20=in_progress, 30=done
        self.output_list = []
        self.node_id_list = node_id_list

    def do(self):
        for m in self.output_list:
            m.output(self.to_dict())

    def output(self, output):
        self.output_list.append(output)
        return self

    def to_dict(self):
        obj = {"id": self.task_id, "list": self.node_id_list, "status": self.status, "spider_no": self.spider_no}
        return obj

